
//1343.大小为k且平均值大于等于阀值的子数组数目
class Solution {
    public:
        int numOfSubarrays(vector<int>& arr, int k, int threshold) {
            int n=arr.size();
            int left=0,right=0;
            int count=0,tmp=0;  //count用来计数，tmp记录每个区间的总和
            while(right<n)
            {
                //入窗口
                while(right-left<k)
                tmp+=arr[right++];
    
                //对答案进行更新
                if(tmp/k>=threshold) count++;
                //出窗口
                tmp-=arr[left++];
            }
            return count;
        }
    };